<!DOCTYPE html>
<html lang="en" >
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <script src="__STATIC__/js/base.js"></script>
    <title>关于我们</title>
    <link rel="stylesheet" href="__STATIC__/css/base.css">
    <link rel="stylesheet" href="__STATIC__/css/userinfo.css">
    <script src="__STATIC__/js/jquery-1.11.1.min.js"></script>
</head>
<body class="">
<section >
    <ul class="buyer_address-list wrap">
        {if condition="$isDefault  neq NUll " }
        <li id="111">
            <div class="buyer_address-info clearfix">
                <div class="pull-left buyer_address-img"><img src="__STATIC__/images/buyer_address.png"></div>
                <div  class="pull-left buyer_address-ins">
                    <span>{$isDefault.linkman} {$isDefault.tel}</span>
                    <span>地址：{$isDefault.province}{$isDefault.city} {$isDefault.district}  {$isDefault.address}</span>
                </div>
            </div>
            <div class="buyer_address-other  clearfix">
                <div class=" pull-left buyer_address-status clearfix">
                    <span class="pull-left"><img src="__STATIC__/images/default-address.png"></span>
                    <span class="pull-left defult-address">默认</span>
                </div>
                <div class="buyer_address-status-change pull-left clearfix">
                    <span class="pull-left"><img src="__STATIC__/images/edit.png"> </span>
                    <span class="pull-left ">编辑</span>
                </div>
                <div class="pull-left clearfix">
                    <span class="pull-left"><img src="__STATIC__/images/delete.png"></span>
                    <span class="pull-left">删除</span>
                </div>
            </div>
            <div class="bar_20"></div>
        </li>
        {/if}
        {volist name="list" id="data" }
        <li id="111">
            <div class="buyer_address-info clearfix">
                <div class="pull-left buyer_address-img"><img src="__STATIC__/images/buyer_address.png"></div>
                <div  class="pull-left buyer_address-ins">
                    <span>{$data.linkman} {$data.tel}</span>
                    <span>地址：{$data.province} {$data.city} {$data.district}  {$data.address}</span>
                </div>
            </div>
            <div class="buyer_address-other  clearfix">
                <div class=" pull-left buyer_address-status clearfix">
                    <span class="pull-left"><img src="__STATIC__/images/address-status.png"></span>
                    <span class="pull-left set">设为默认</span>
                </div>
                <div class="buyer_address-status-change pull-left clearfix">
                    <span class="pull-left"><img src="__STATIC__/images/edit.png"> </span>
                    <span class="pull-left editaddress">编辑</span>
                </div>
                <div class="pull-left clearfix">
                    <span class="pull-left"><img src="__STATIC__/images/delete.png"></span>
                    <span class="pull-left dele">删除</span>
                </div>
            </div>
            <div class="bar_20"></div>
        </li>
        {/volist}
    </ul>
    <script>
        $(".editaddress").on('click',function(){
            /***获取要修改的地址id**/
            var shipaddressid=  $(this).parent().attr('shipaddressid');
            // alert(shipaddressid); 发送ajax请求
            //弹框
            var title = "";
            var url = "{:url('editshippingaddress')}?shipaddressid=" + shipaddressid;
            layer_layer2(title,url,'800px','468px');

        });
        //删除行
        $('.dele').click(function(){
            /***获取要修改的地址id**/
            var shipaddressid=  $(this).parent().attr('shipaddressid');
            var thisself = $(this)
            //  alert(shipaddressid); 发送ajax请求，成功后删除
            $.ajax({
                url : "{:\\think\\Url::build('deleAddress')}",
                type: "POST",
                data : {shipaddressid:shipaddressid},
                success: function(data)
                {
                    //data - response from server
                    if(data.code == 'ok'){
                        thisself.parent().remove();
                    } else {

                    }
                },
                error: function (jqXHR)
                {
                }
            });

        });
        $(function(){
            $('.buyer_address-list .buyer_address-info').on('click',function(){
                var url=document.referrer;
                //从订单确认面过来的则是选择收货地址，跳回订单确认页面
                var sear=new RegExp('/confirm.html');
                if(sear.test(url)){
                    var id = $(this).parent().attr('id');
                    window.location.href= '/confirm.html?addressId='+id;
                }
            });
        });
    </script>
    <a class="add-address"  href="/editshippingaddress.html">添加买家信息</a>
</section>
</body>
</html>